package pk2;

public class Person {
    private String name;
    private int age;
    public  Person(){

    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }


    public void KeepPet(Animal a,String something){
        if(a instanceof Dog dog){/*子类才能调用特定方法，要把父类类型转为子类类型*/
            System.out.println("年龄为"+age+"岁的"+name+"养了一只"+a.getColor()+"颜色的狗");
            System.out.println(a.getAge()+"岁的"+a.getColor()+"颜色的狗两条前腿死死抱住"+something+"猛吃");
            dog.lookHome();
        }
        else if(a instanceof Cat cat){
            System.out.println("年龄为"+age+"岁的"+name+"养了一只"+a.getColor()+"颜色的猫");
            System.out.println(a.getAge()+"岁的"+a.getColor()+"颜色的猫眯着眼睛侧着头吃"+something);
            cat.catchMouse();
        }


    }


}
